using System;
using System.Data;
using Npgsql;
using Gtk;

namespace PNpgsql
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string connectionString =
	          "Server=localhost;" +
	          "Database=dbprueba;" +
	          "User ID=dbprueba;" +
	          "Password=sistemas;";
		    IDbConnection dbcon;
		    dbcon = new NpgsqlConnection(connectionString);
		    dbcon.Open();
		    
		    dbcon.Close();
				
			Application.Init ();
			MainWindow win = new MainWindow ();
			win.Show ();
			Application.Run ();
		}
		
		public static string Select(IDbConnection dbcon)
		{
			IDbCommand dbcmd = dbcon.CreateCommand();
		    // requires a table to be created named employee
		    // with columns firstname and lastname
		    // such as,
		    //        CREATE TABLE employee (
		    //           firstname varchar(32),
		    //           lastname varchar(32));
		    string sql =
		        "SELECT nombre " +
		        "FROM articulo";
		    dbcmd.CommandText = sql;
		    IDataReader reader = dbcmd.ExecuteReader();
		    while(reader.Read()) {
		         string nombre = reader.GetString(reader.GetOrdinal("nombre"));
		         Console.WriteLine("Nombre: " +
		              nombre);
		    }
		    // clean up
		    reader.Close();
		}
	}
}
